class CommentGrade < ActiveRecord::Base
  belongs_to :user
  belongs_to :comment
  
  def CommentGrade.canVoteThisComment(userId,commentId)
  	commGrade = (CommentGrade.find(:first , :conditions => "user_id = #{userId} AND comment_id = #{commentId}"))
  	comm = Comment.find(commentId)
  	 return (commGrade.nil? and (comm.user_id != userId))
  end
  
  def CommentGrade.getVoteThisComment(userId,commentId)
  grade = 0
  comment = (CommentGrade.find(:first , :conditions => "user_id = #{userId} AND comment_id = #{commentId}"))
  	 if (not comment.nil?) then
  	 	grade = comment.evaluation
  	 end
  return grade
  end
end
